<template>
  <el-row class="bid-box">
    <material-table :datalist="list" v-if='list.length>0'></material-table>
    <e-placeholder v-else text="暂时没有收到素材哦~"></e-placeholder>
  </el-row>
</template>
<script>
  import {form} from 'utils/mixins' // 引入form mixin
  import MaterialTable from './components/MaterialTable'
  import api from 'api/merchants'
  // import api from 'api/sponsor'
  export default{
    mixins: [form],
    components: {
      MaterialTable
    },
    props: {
      id: {}
    },
    data () {
      return {
        activeNames: [1, 2],
        dialogFormVisible: false,
        opening: false,
        list: []
      }
    },
    created () {
      this.getList()
    },
    methods: {
      getList () {
        api.bidfodder_list({
          merId: this.id
        }).then((json) => {
          json.data = this.maplist(json.data, {check: false})
          this.list = json.data
        })
      },
      maplist (list, option) {
        // 递归修改json的值
        let result = Object.assign([], list)
        result.forEach(item => {
          for (var m in option) {
            item[m] = option[m]
          }
          if (item.list) {
            this.maplist(item.list, option)
          }
        })
        return result
      }
    }
  }
</script>
<style lang="scss">
  .bid-box{
    padding:10px;
    .el-collapse{
      border-left:0px;
      border-right:0px;
    }
  }

</style>
